<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class Admin_news_model extends CI_Model {
    function news_model()
    {
        parent::__construct();
        
    }
    function get_all_news($num=NULL, $offset=NULL)
    {
        $subcond="where status=51";
        $limit="";
        if (isset($num) && isset($offset))
            $limit=" limit $offset, $num";
        $sql="select * from news ".$subcond.$limit;
        $query=$this->db->query($sql);
        $result=$query->result();
        return $result;
    }
    function get_news($id=NULL)
    {
       $sql="select * from news where id=$id and status=51";
       $query=$this->db->query($sql);
       $row=$query->row();
       return $row;
    }
    function insert_news($title=NULL,$url,$detail=NULL,$meta_title=NULL,$meta_keyword=NULL,$meta_description=NULL)
    {
	
        $date=date('d-M-Y');
        $sql="insert into news (title,url,description,date,meta_title,meta_keyword,meta_description) values('$title','$url','$detail','$date','$meta_title','$meta_keyword','$meta_description')";
        $this->db->query($sql);
    }
    function update_news($id=NULL,$url=NULL,$title=NULL,$detail=NULL,$meta_title=NULL,$meta_keyword=NULL,$meta_description=NULL)
    {
	
        $date=date('d-M-Y');
        $sql="update news set `title`='$title',`url`='$url',`description`='$detail',meta_title='$meta_title',meta_keyword='$meta_keyword',meta_description='$meta_description',`updated_on`='$date' where id='$id'";
		
        $this->db->query($sql);
    }
    
    function delete_news($id=NULL)
    {
        $sql="delete from news where id=$id";
        $this->db->query($sql);
        
    }
    
}
?>
